home *** CD-ROM | disk | FTP | other *** search
/ Programming Windows (5th Edition) / Programming Windows, 5th ed. - Companion CD (097-0002183)(1999).iso / Chap13 / Print1 / Print1.c < prev    next >
Encoding:
C/C++ Source or Header  |  1998-10-09  |  1.2 KB  |  46 lines

  1. /*---------------------------------------
  2.    PRINT1.C -- Bare Bones Printing
  3.                (c) Charles Petzold, 1998
  4.   ---------------------------------------*/
  5.  
  6. #include <windows.h>
  7.  
  8. HDC  GetPrinterDC (void) ;              // in GETPRNDC.C
  9. void PageGDICalls (HDC, int, int) ;     // in PRINT.C
  10.  
  11. HINSTANCE hInst ;
  12. TCHAR     szAppName[] = TEXT ("Print1") ;
  13. TCHAR     szCaption[] = TEXT ("Print Program 1") ;
  14.  
  15. BOOL PrintMyPage (HWND hwnd)
  16. {
  17.      static DOCINFO di = { sizeof (DOCINFO), TEXT ("Print1: Printing") } ;
  18.      BOOL           bSuccess = TRUE ;
  19.      HDC            hdcPrn ;
  20.      int            xPage, yPage ;
  21.      
  22.      if (NULL == (hdcPrn = GetPrinterDC ()))
  23.           return FALSE ;
  24.  
  25.      xPage = GetDeviceCaps (hdcPrn, HORZRES) ;
  26.      yPage = GetDeviceCaps (hdcPrn, VERTRES) ;
  27.      
  28.      if (StartDoc (hdcPrn, &di) > 0)
  29.      {
  30.           if (StartPage (hdcPrn) > 0)
  31.           {
  32.                PageGDICalls (hdcPrn, xPage, yPage) ;
  33.                
  34.                if (EndPage (hdcPrn) > 0)
  35.                     EndDoc (hdcPrn) ;
  36.                else
  37.                     bSuccess = FALSE ;
  38.           }
  39.      }
  40.      else
  41.           bSuccess = FALSE ;
  42.      
  43.      DeleteDC (hdcPrn) ;
  44.      return bSuccess ;
  45. }
  46.